package com.boge.study.design_pattern.builder;

public class Student {

    private String name;
    private int age;
    private int height;
    private int sex;

    //扩展信息
    private  String idCard;
    private String stuNo;
    private String labName;
    private String dormitoryAddress;

    private Student(Builder builder) {
        this.name = builder.name;
        this.age = builder.age;
        this.height = builder.height;
        this.sex = builder.sex;

        this.idCard = builder.idCard;
        this.stuNo = builder.stuNo;
        this.labName = builder.labName;
        this.dormitoryAddress = builder.dormitoryAddress;
    }

    //通过这个内部类来实例化Student对象
    public static class Builder{
        private String name;
        private int age;
        private int height;
        private int sex;

        //扩展信息
        private String idCard;
        private String stuNo;
        private String labName;
        private String dormitoryAddress;

        public Builder(String name, int age, int height, int sex) {
            super();
            this.name = name;
            this.age = age;
            this.height = height;
            this.sex = sex;
        }

        public Builder setIdCard(String idCard) {
            this.idCard = idCard;
            return this;
        }

        public Builder setStuNo(String stuNo) {
            this.stuNo = stuNo;
            return this;
        }

        public Builder setLabName(String labName) {
            this.labName = labName;
            return this;
        }

        public Builder setDormitoryAddress(String dormitoryAddress) {
            this.dormitoryAddress = dormitoryAddress;
            return this;
        }

        //构造器入口
        public Student build() {
            return new Student(this);
        }

    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", height=" + height +
                ", sex=" + sex +
                ", idCard='" + idCard + '\'' +
                ", stuNo='" + stuNo + '\'' +
                ", labName='" + labName + '\'' +
                ", dormitoryAddress='" + dormitoryAddress + '\'' +
                '}';
    }

}
